package com.kui.trytodo.springmvc.chapter13;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {

    @GetMapping(value = "login")
    public String login(String username, String password) {
        if (username == null || username.length() == 0) {
            throw new UsernameException("用户名不合法");
        }
        if (password == null || password.length() == 0) {
            throw new PasswordException("密码不合法");
        }
        if (!username.equals("admin") || !password.equals("123456")) {
            throw new RuntimeException("账户密码不正确");
        }
        System.out.println("登录成功");
        return "success";
    }
}
